package com.ln.cmsln.controller;


import com.ln.cmsln.pojo.entity.Photo;
import com.ln.cmsln.pojo.entity.Relation;
import com.ln.cmsln.service.RelationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wuwenzhe
 * @since 2022-03-31
 */
@Api(tags = "联系我们")
@CrossOrigin
@RestController
@RequestMapping("/api/relation")
public class RelationController {

        @Resource
        private RelationService relationService;

    @ApiOperation("列表信息")
    @GetMapping("/all")
    public  Object  getAll(){
        List<Relation> list = relationService.list(null);
        HashMap<String, Object> map = new HashMap<>();
        map.put("code",0);
        map.put("count",0);
        map.put("data",list);
        return  map;
    }
    @ApiOperation("删除列表信息")
    @PostMapping("remove")
    public  boolean  delById(Long rid){

        //根据id删除
        boolean b = relationService.removeById(rid);
        return b;
    }
    @ApiOperation("增加列表信息")
    @PostMapping("save")
    public  boolean add(@ApiParam(value = "新增图片信息", required = true)Relation relation

    ){

        return  relationService.save(relation);
    }


}

